<div class="row-fluid">
    <div class="span12">
        <div class="grid simple">
            <div class="grid-body no-border email-body">
                <?php
                /* @var $this NewModelsController */
                /* @var $model NewModels */


                $this->breadcrumbs = array(
                    'New Models' => array('index'),
                    'Управление',
                );
                ?>
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'enableAjaxValidation' => true,
                    'action' => '/x8/newModels/add'
                ));
                ?>
                <br />
                <?php
                $this->widget('bootstrap.widgets.TbGridView', array(
                    'id' => 'new-models-grid',
                    'dataProvider' => $model->search(),
                    'filter' => $model,
                    'rowCssClassExpression' => '$data->getClass()',
                    'columns' => array(
                        //'row_id',
                        array(
                            'id' => 'row_id',
                            'class' => 'CCheckBoxColumn',
                            'selectableRows' => '50',
                        ),
                        //'cat_id',
                        'cat_title',
                        //'brand_id',
                        'brand_title',
                        //'model_id',
                        'model_title',
                        //'model_image',
                        //'model_rating',
                        'model_price',
                        //'model_popular',
                        'model_yandex_id',
//                        'model_added_date',
                        //'is_active',
                        //'is_parent',
                        //'model_test_title',
                        //'model_status',
                        array(
                            'name' => 'model_added_date',
                            'header' => 'Дата',                            
                            'value' => 'date("d-m-Y", $data->model_added_date)'
                        ),
                        array(
                            'name' => 'model_status',
                            'header' => 'Статус',
                            'filter' => array('added' => 'Добавлена на сайт', 'rejected' => 'Отклонена', 'new' => 'Новая', 'linked' => 'Прикреплена к осн. модели'),
                            'value' => '$data->getStatusText()'
                        ),
                        array(
                            'class' => 'bootstrap.widgets.TbButtonColumn',
                            'template' => '{add}{attach}{view}{update}{delete}',
                            'buttons' => array(
                                'add' => array(
                                    'label' => 'Добавить на сайт',
                                    'url' => 'CHtml::normalizeUrl(array("newModels/addOne", "id" => $data->row_id))',
                                    'imageUrl' => Yii::app()->theme->baseUrl . '/assets/img/add.png',
                                    'visible' => '$data->model_status == "new" ? 1 : 0',
                                ),
                                'attach' => array(
                                    'label' => 'Прикрепить',
                                    'url' => 'CHtml::normalizeUrl(array("newModels/attach", "id" => $data->row_id))',
                                    'imageUrl' => Yii::app()->theme->baseUrl . '/assets/img/attach.png',
                                    //'visible' => '$data->model_status == "added" ? 1 : 0',
                                ),
                            ),
                        ),
                    ),
                ));
                ?>
                <br />
                <div>        
                    <?php echo CHtml::submitButton('Добавить на сайт', array('class' => 'btn btn-success btn-large', 'id' => 'button_left3')); ?>
                    <?php echo CHtml::ajaxSubmitButton('Отклонить', array('newModels/ajaxupdate', 'act' => 'doInactive'), array('success' => 'reloadGrid'), array('class' => 'btn btn-danger btn-large', 'id' => 'button_left')); ?>
                    <?php echo CHtml::ajaxSubmitButton('Удалить', array('newModels/ajaxdelete'), array('success' => 'reloadGrid'), array('class' => 'btn btn-warning btn-large', 'confirm' => 'Точно удалить?')); ?>
                </div>
                <?php $this->endWidget(); ?>
            </div>
        </div>	
    </div>
</div>
<script>
    function reloadGrid(data) {
        $.fn.yiiGridView.update('new-models-grid');
    }
</script>
<style>
    table.items tr.new {
        background: none repeat scroll 0 0 #71D688 !important;
    }

    table.items tr.added {
        background: none repeat scroll 0 0 #53A2DD !important;
    }

    table.items tr.linked {
        background: none repeat scroll 0 0 #F9F98E !important;
    }

    table.items tr.rejected {
        background: none repeat scroll 0 0 #FF9166 !important;
    }
</style>